/*
    This file is part of the substandard lisp implementation of Standard Lisp
    Copyright (C) 2011 Nicky Nickell

    substandard lisp is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/*
    builtins related to variables as defined in section 3.6 of the
    The Standard Lisp Report
*/

function std_fluid(a, env) {
  var idlist = a[0];

  throw new Error('FLUID not implemented (yet)');
}
builtins['fluid'] = new builtin_function(std_fluid, 1, false, [TYPE_PAIR], FTYPE_EXPR);

function std_fluidp(a, env) {
  var u = a[0];

  throw new Error('FLUIDP not implemented (yet)');
}
builtins['fluidp'] = new builtin_function(std_fluidp, 1, false, [CLASS_ANY], FTYPE_EXPR);

function std_global(a, env) {
  var idlist = a[0];

  throw new Error('GLOBAL not implemented (yet)');
}
builtins['global'] = new builtin_function(std_global, 1, false, [TYPE_PAIR], FTYPE_EXPR);

function std_globalp(a, env) {
  var u = a[0];

  throw new Error('GLOBALP not implemented (yet)');
}
builtins['globalp'] = new builtin_function(std_globalp, 1, false, [CLASS_ANY], FTYPE_EXPR);

function std_set(a, env) {
  var expr = a[0];
  var value = a[1];

  env.variables.set(expr.value, value);

  return value;
}
builtins['set'] = new builtin_function(std_set, 2, false, [TYPE_ID, CLASS_ANY], FTYPE_EXPR);

function std_setq(a, env) {
  var variable = a[0];
  var value = a[1];

  value = evaluate(value, env);
  env.variables.set(variable.value, value);

  return value;
}
builtins['setq'] = new builtin_function(std_setq, 2, false, [TYPE_ID, CLASS_ANY], FTYPE_FEXPR);

function std_unfluid(a, env) {
  var idlist = a[0];

  throw new Error('UNFLUID not implemented (yet)');
}
builtins['unfluid'] = new builtin_function(std_unfluid, 1, false, [TYPE_PAIR], FTYPE_EXPR);
